<%@include file="common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>   
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<title>修改密码</title>

<script>
$(function() {
	$('#saveBtn').click(doOK);
	
});

//CharMode函数 
//测试某个字符是属于哪一类. 
function CharMode(iN){ 
	if (iN>=48 && iN <=57) //数字 
		return 1; 
	if (iN>=65 && iN <=90) //大写字母 
		return 2; 
	if (iN>=97 && iN <=122) //小写 
		return 4; 
	else 
		return 8; //特殊字符 
} 
//bitTotal函数 
//计算出当前密码当中一共有多少种模式 
function bitTotal(num){ 
	modes=0; 
	for (i=0;i<4;i++){ 
	if (num & 1) modes++; 
		num>>>=1; 
	} 
	return modes; 
} 
//checkStrong函数 
//返回密码的强度级别 
function checkStrong(sPW){ 
	if (sPW.length<=4) 
		return 0; //密码太短 
	Modes=0; 
	for (var i=0;i<sPW.length;i++){ 
		//测试每一个字符的类别并统计一共有多少种模式. 
		Modes|=CharMode(sPW.charCodeAt(i)); 
	} 
	return bitTotal(Modes); 
} 
//pwStrength函数 
//当用户放开键盘或密码输入框失去焦点时,根据不同的级别显示不同的颜色 
function pwStrength(pwd){ 
	O_color="#eeeeee"; 
	L_color="#FF0000"; 
	M_color="#FF9900"; 
	H_color="#33CC00"; 
	if (pwd==null||pwd==''){ 
		Lcolor=Mcolor=Hcolor=O_color; 
	} 
	else{ 
		S_level=checkStrong(pwd); 
		switch(S_level) { 
		case 0: 
			Lcolor=Mcolor=Hcolor=O_color; 
		case 1: 
			Lcolor=L_color; 
			Mcolor=Hcolor=O_color; 
			break; 
		case 2: 
			Lcolor=Mcolor=M_color; 
			Hcolor=O_color; 
			break; 
		default: 
			Lcolor=Mcolor=Hcolor=H_color; 
		} 
	} 
	document.getElementById("strength_L").style.background=Lcolor; 
	document.getElementById("strength_M").style.background=Mcolor; 
	document.getElementById("strength_H").style.background=Hcolor; 
	
	document.getElementById('mmqd').style.display="";
	if(isEmpty(document.getElementById('txtNewPass').value)){
		document.getElementById('mmqd').style.display="none";
	}
	return; 
} 

function doOK(){
	var opeForm = $('#opeForm');
	
    var oldpass = $('#txtOldPass');
    var newpass = $('#txtNewPass');
    var rePass = $('#txtRePass');

    if (oldpass.val() == '') {
        showInfoWin("请输入当前密码！");
        return;
    }
    if (newpass.val() == '') {
        showInfoWin("请输入新密码！");
        return;
    }
    if (rePass.val() == '') {
        showInfoWin("请再一次确认密码！");
        return;
    }

    if (newpass.val() != rePass.val()) {
        showInfoWin("两次密码不一致！请重新输入！");
        return;
    }

	var options = {
		url : 'doChangePass.do',
		type : 'post',
		success : function(operationType) {
			if (operationType == '99') {
				showInfoWin("操作成功!", function() {window.location.href = 'showMain.do';});
			} else {
				showInfoWin("操作成功!", function() {window.close();});
			}
		}
	};
	opeForm.ajaxSubmit(options);
}

</script>
</head>

<body>
<form id="opeForm" name="opeForm" method="post" action="doChangePass.do">

<input type="hidden" id="usr_id" name="model.usr_id" value="${model.usr_id}"> </input>

<input type="hidden" id="operationType" name="operationType" value="${operationType}" />

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="editDisplay">
    <tr>
        <td valign="top">
        <%--编辑页面名称标题表格--%>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="editCaption">
            <tr>
                <td height="30">&nbsp;</td>
            </tr>
            <tr>
                <td align="center"><font class="editCaptionTitle">修改密码</font></td>
            </tr>
            <tr>
                <td height="10"></td>
            </tr>
        </table>
	<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="editTableBorder" style="width:600px;">
	    <tr>
	        <td >
	        <%--编辑部分表格--%>
	             <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" style="width:650px;">
	                    <tr>    
	                        <td class="editMainLabelTD" nowrap="nowrap" align="right" style="width: 40%">用户姓名：&nbsp;</td>
	                        <td class="editMainTD" nowrap="nowrap" align="left" style="width: 60%">
	                          ${model.usr_name}
	                        </td>
	                    </tr>
	                    
	                    <tr>
			                <td class="editMainLabelTD" nowrap="nowrap" align="right" nowrap="nowrap">当前密码：</td>
			                <td class="editMainTD"  align="left" nowrap="nowrap">
			                	<input id="txtOldPass" name="model.static_pwd_md5" type="password" required="true" class="easyui-validatebox editMainText"  maxlength="50"/>&nbsp;<font color="red">*</font>
			                </td>
	                    </tr> 
	                    
	                    <tr>
			                <td class="editMainLabelTD" nowrap="nowrap" align="right" nowrap="nowrap">新密码：</td>
			                <td class="editMainTD"  align="left" nowrap="nowrap">
			                	<input id="txtNewPass" name="model.new_static_pwd_md5" type="password" required="true" class="easyui-validatebox editMainText"  maxlength="50"/>&nbsp;<span><font color="red">*</font></span>&nbsp;
			                </td>
	                    </tr>
	        
	                    <tr>
			                <td class="editMainLabelTD" nowrap="nowrap" align="right" nowrap="nowrap">确认密码：</td>
			                <td class="editMainTD"  align="left" nowrap="nowrap">
			                	<input id="txtRePass" name="model.re_new_static_pwd_md5" type="password" required="true" class="easyui-validatebox editMainText"  maxlength="50"/>&nbsp;<span><font color="red">*</font></span>
			                </td>
	                    </tr> 
	                    
	                    <tr>
		                    <td class="editMainConstTD" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密码规则：
		                    	数字：&nbsp;${d_pwd_policy.number_count} &nbsp;位，
		                    	大写字母：&nbsp;${d_pwd_policy.upper_count} &nbsp;位，
		                    	小写字母：&nbsp;${d_pwd_policy.lower_count} &nbsp;位，
		                    	特殊字符：&nbsp;${d_pwd_policy.special_count} &nbsp;位，
		                    	&nbsp;&nbsp;密码最大长度：&nbsp;${d_pwd_policy.max_length} &nbsp;位
		                    	 	                    	 
		                    </td>
	                    </tr> 	   
	                    <tr>
	                    	<td class="editMainConstTD" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数字包含：${model.number_seed }</td>
	                    </tr>	                                     
	                    <tr>
	                    	<td class="editMainConstTD" colspan="2">&nbsp;&nbsp;大写字母包含：${model.upper_seed }</td>
	                    </tr>	
	                    <tr>
	                    	<td class="editMainConstTD" colspan="2">&nbsp;&nbsp;小写字母包含：${model.lower_seed }</td>
	                    </tr>	
	   
	                    <tr>
	                    	<td class="editMainConstTD" colspan="2">&nbsp;&nbsp;特殊字符包含：${model.special_seed }</td>
	                    </tr>	   	                    	                                                            
	                    <tr>
	                       <td class="editMainConstTD" colspan="4">&nbsp;&nbsp;说明：带<span><font color="red">*</font></span>的项目是必须填写项</td>
	                    </tr>    
	                    
	             </table>
	        </td>
	    </tr>
	    <tr>
	      <td colspan="3" class="editMainBottomTD">&nbsp;
	            <div style="text-align: center; padding: 5px;">
	                  <a href="javascript:void(0)" id="saveBtn" class="easyui-linkbutton" icon="icon-save">保存</a>
				</div>   
		  </td>
	    </tr>
	</table>
	</td>
   </tr>
</table>

</form>
</body>
</html>